/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bookingtickets;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author alexxxey
 */
@Entity
@Table(name = "DESTINATIONS")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "Destination.findAll", query = "SELECT d FROM Destination d"),
    @NamedQuery(name = "Destination.findById", query = "SELECT d FROM Destination d WHERE d.id = :id"),
    @NamedQuery(name = "Destination.findByDest", query = "SELECT d FROM Destination d WHERE d.dest = :dest"),
    
    @NamedQuery(name = "Destination.findTripByDest", query = "SELECT d.tripid FROM Destination d WHERE d.dest = :dest"),
    
})
public class Destination implements Serializable
{
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID")
    private Integer id;
    @Size(max = 32)
    @Column(name = "DEST")
    private String dest;
    @JoinColumn(name = "TRIPID", referencedColumnName = "ID")
    @ManyToOne(fetch = FetchType.EAGER)
    private Trip tripid;

    public Destination()
    {
    }

    public Destination(Integer id)
    {
        this.id = id;
    }

    public Integer getId()
    {
        return id;
    }

    public void setId(Integer id)
    {
        this.id = id;
    }

    public String getDest()
    {
        return dest;
    }

    public void setDest(String dest)
    {
        this.dest = dest;
    }

    public Trip getTripid()
    {
        return tripid;
    }

    public void setTripid(Trip tripid)
    {
        this.tripid = tripid;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Destination))
        {
            return false;
        }
        Destination other = (Destination) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "bookingtickets.Destination[ id=" + id + " ]";
    }
    
}
